Skip to content

Fix Expense-Scan expense from Inbox briefly shows Inbox with growl before redirecting to workspace - #103826

Merged
roryabraham merged 6 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-scan-expense-navigation-from-inbox
Nov 7, 2026
Merged

roryabraham merged 6 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-scan-expense-navigation-from-inbox

Conversation

@GCyganek

Copy link
Copy Markdown
Contributor

Explanation of Change

Picking another workspace in the confirmation "To" picker left report undefined because the route still pointed at the old workspace chat. With no destinationReportID, the chat was not pre-mounted and submit took the DEFAULT path, briefly showing the Inbox. IOURequestStepConfirmation now falls back to the picked workspace chat, so it is pre-inserted and revealed directly.

Fixed Issues

$ #102858
PROPOSAL: N/A

Tests

  1. Launch app -onboarding via track business expenses
  2. From inbox , create a scan expense via camera image entering description
  3. Note user directed to workspace chat and growl is shown
  4. Go to workspace settings and create new workspace
  5. Go to inbox
  6. Tap fab - create expense - scan
  7. Select new workspace created and create a scan expense via camera image entering description
  8. Verify Scan expense created from inbox directed to workspace chat and growl is shown without briefly showing inbox before redirection.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-10-13.at.08.25.22.mov
Android: mWeb Chrome
iOS: Native
Screen.Recording.2026-10-13.at.08.53.42.mov
iOS: mWeb Safari
MacOS: Chrome / Safari

@GCyganek

Copy link
Copy Markdown
Contributor Author

TS check failure not related to my changes, fails on main as well

@GCyganek
GCyganek marked this pull request as ready for review October 13, 2026 08:49
@GCyganek
GCyganek requested review from a team as code owners October 13, 2026 08:49
@melvin-bot
melvin-bot Bot requested review from abdulrahuman5196 and dylanexpensify and removed request for a team October 13, 2026 08:49
@melvin-bot

melvin-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

@abdulrahuman5196 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T09:02:34.508965Z d4eeb0a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4eeb0aa69

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// Picking another workspace in the "To" picker moves the transaction to that workspace chat while the route still points
// at the previous one, so `report` resolves to undefined. Fall back to the picked workspace chat
// so the destination can still be pre-mounted instead of revealing the Inbox before navigating there.
const pickedWorkspaceChatReportID = !isUnreported && isPolicyExpenseChatUtils(participantReport) ? participantReport?.reportID : undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve the picked workspace from the active receipt

When a global-create scan contains multiple draft receipts and the user advances to a later receipt before changing its To workspace, participantReport is still subscribed from initialTransaction (line 154), while transaction and the picker operate on currentTransactionID. This fallback therefore pre-inserts the first receipt's workspace; the report-preinsert submit path then disables the action's own navigation, so the expenses are written using the active receipt's participant but the user is left in the old workspace. Resolve the fallback report from the active transaction instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, although I'm not sure if this is not a bug when we submit multiple scan expenses with different recipients and they still end up being added to one of them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dylanexpensify
dylanexpensify previously approved these changes Oct 13, 2026

@dylanexpensify dylanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a product perspective 👍

@GCyganek

Copy link
Copy Markdown
Contributor Author

@abdulrahuman5196 in case you missed it

@abdulrahuman5196

Copy link
Copy Markdown
Contributor

Hi, Will check on thi

@mountiny
mountiny requested review from situchan and removed request for abdulrahuman5196 November 6, 2026 14:37
Comment on lines +90 to +91
const pickedParticipant = transaction?.participants?.at(0);
const pickedWorkspaceChatReportID = !isUnreported && isPolicyExpenseChat(pickedParticipant) ? pickedParticipant?.reportID : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate "first participant" variable

pickedParticipant reads transaction?.participants?.at(0), but the hook already has firstParticipant = participants.at(0) a few lines below.
participants maps transaction.participants one to one and keeps reportID and isPolicyExpenseChat, so both hold the same participant under different names.

Move firstParticipant above this block and use isPolicyExpenseChat(firstParticipant) ? firstParticipant?.reportID : undefined.

// Picking another workspace in the "To" picker moves the transaction to that workspace chat while the route still points
// at the previous one, so `report` resolves to undefined. Fall back to the picked workspace chat
// so the destination can still be pre-mounted instead of revealing the Inbox before navigating there.
const isUnreported = transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUnreported computed twice

The page already computes the same value and passes it to the orchestrator.
The hook takes the page's other flags as params.

const isUnreported = transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;

Add isUnreported to UseSubmitDestinationPreMountParams and pass it from the page.

Comment on lines +86 to +91
// Picking another workspace in the "To" picker moves the transaction to that workspace chat while the route still points
// at the previous one, so `report` resolves to undefined. Fall back to the picked workspace chat
// so the destination can still be pre-mounted instead of revealing the Inbox before navigating there.
const isUnreported = transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
const pickedParticipant = transaction?.participants?.at(0);
const pickedWorkspaceChatReportID = !isUnreported && isPolicyExpenseChat(pickedParticipant) ? pickedParticipant?.reportID : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported guard has no reason

The comment explains the fallback but not why unreported expenses are skipped.
Categorizing a tracked expense into a new draft workspace leaves it unreported with a workspace chat participant, so the guard reads like a bug.

Add one sentence on where an unreported expense lands and why the participant's chat is the wrong destination for it.

Comment on lines +1613 to +1616
it('pre-mounts the workspace chat picked on the receipt being viewed when there are multiple receipts', async () => {
// Given a global create with two receipts, where the first one is still on the default workspace chat the route
// was seeded with and the "To" picker moved only the second one to another workspace chat. The picker writes to the
// receipt being viewed, so the route's (first) transaction no longer reflects where the expenses are submitted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-receipt test sets up an unreachable state

The Given says the "To" picker moved only the second receipt.
The picker writes the pick to every receipt in the batch, so receipts on different workspaces can't happen in the app.

// Every receipt of a multi-scan batch is submitted to the shown receipt's recipient, so the pick applies to all
// of them, like useParticipantSubmission does.
if (shouldKeepOnSelfDM) {
for (const transactionToUpdate of transactions) {

Seed both drafts with the picked chat, or reword the Given.

@situchan

situchan commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@situchan situchan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Left some nab comments

@melvin-bot

melvin-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #102858 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@melvin-bot
melvin-bot Bot requested a review from roryabraham November 6, 2026 15:20

@roryabraham roryabraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree @situchan's comments are NAB

@roryabraham
roryabraham merged commit f507215 into Expensify:main Nov 7, 2026
37 of 41 checks passed
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Nov 7, 2026
85 tasks done
@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.34-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed — this PR only fixes navigation after selecting a different workspace for an expense, preventing a brief Inbox flash without adding new UI, screens, or user properties.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR fixes a brief navigation flicker after creating an expense, restoring expected behavior without adding a feature or making existing article instructions incorrect.


view run

@OSBotify

OSBotify commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.34-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants